package com.lindroy.jetpacknotes.viewmodel

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.PersistableBundle
import com.lindroy.jetpacknotes.R
import kotlinx.android.synthetic.main.activity_edit_text.*


private const val KEY_INPUT = "input"
class EditTextActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_edit_text)
        //Activity 创建时取出保存的文本
        savedInstanceState?.also {
            etInput.setText(it.getString(KEY_INPUT))
        }
    }

    /**
     *  Activity 销毁时保存 EditText 中的文本
     */
    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        outState.putString(KEY_INPUT,etInput.text.toString())
    }

}